function exposeTestFunctionNames() {
    return ['testSetMaxGoNoGo',
//    'testHashEquals', 'testNewHash', 'testPutItem',
//		    'testSort', 'testAssertHashEquals', 'testToString',
    ];
    }
var hash = null;
    
function setUp() {
	hash = new Hash();
}
    
function tearDown() {
	debug( '<br/>' + hash.len() + '<br/>' + hash.toString() );
}


function testNewHash() {
	assertNotNull('failed Null', hash);
}


function testPutItem() {
	hash.putItem('person', 'name', 'joe');
    assertTrue(hash.has("person"));
}


function testHashEquals() {
	var obj1 = {
    	joePerson: { "name": "joe", hobby: "reading" },
    	suePerson: { "name": "sue", age: 40 }
	};
	hash.putItem('joePerson', 'name', 'joe');
	hash.putItem('joePerson', 'hobby', 'reading');
	hash.putItem('suePerson', 'name', 'sue');
	hash.putItem('suePerson', 'age', 40);
    assertTrue(hash.has("joePerson"));
    assertTrue(hash.has("suePerson"));
    assertObjectEquals( obj1, hash.hashArr );
    debug( obj1.toSource() + '<br/>' + hash.hashArr.toSource() );
	assertHashEquals( 'a/= toSource' + obj1.toString(), obj1.toString(), hash.hashArr.toString() );
}


function testAssertHashEquals() {
    var hash1 = new Array();
    hash1["key1"] = "value1";
    hash1["key2"] = "value2";

    var hash2 = new Array();
    try {
        assertHashEquals(hash1, hash2);
        fail();
    } catch (e) {
        assertJsUnitException("hash2 is empty", e);
    }
    hash2["key1"] = "value1";
    try {
        assertHashEquals(hash1, hash2);
        fail();
    } catch (e) {
        assertJsUnitException("hash2 is a of a different size", e);
    }
    hash2["key2"] = "foo";
    try {
        assertHashEquals(hash1, hash2);
        fail();
    } catch (e) {
        assertJsUnitException("hash2 has different values", e);
    }
    hash2["key2"] = "value2";
    assertHashEquals(hash1, hash2);
}

function assertJsUnitException(comment, allegedJsUnitException) {
    assertNotNull(comment, allegedJsUnitException);
    assert(comment, allegedJsUnitException.isJsUnitException);
    assertNotUndefined(comment, allegedJsUnitException.comment);
}

function testSort(){
	var hash = new Hash();
	hash.putItem('joePerson', 'name', 'joe');
	hash.putItem('joePerson', 'hobby', 'reading');
	hash.putItem('suePerson', 'name', 'sue');
	hash.putItem('suePerson', 'age', 40);
	var lilRec = { "name": "lil", "age": '40' };
	hash.putRec('lilPerson', lilRec);
	var jillRec = { "name": "jill", "pet": 'joe', 'auto': 'pinto' };
	hash.putRec('jillPerson', jillRec);
	hash.putItem('aPerson', 'car', 'ford');
	var resStr = 'aPerson => car: ford, jillPerson => name: jill, pet: joe, auto: pinto, joePerson => name: joe, hobby: reading, lilPerson => name: lil, age: 40, suePerson => name: sue, age: 40';
	hash = hash.sort();
	assertEquals( 'a/= hash sorted', resStr, hash.toString() );
}

function testToString(){
	var hash = new Hash();
	hash.putItem('joePerson', 'name', 'joe');
	hash.putItem('joePerson', 'hobby', 'reading');
	hash.putItem('suePerson', 'name', 'sue');
	hash.putItem('suePerson', 'age', 40);
	var lilRec = { "name": "lil", "age": '40' };
	hash.putRec('lilPerson', lilRec);
	hash.putItem('aPerson', 'car', 'ford');
	debug( 'toString', hash.toString());
	var resStr = 'joePerson => name: joe, hobby: reading, '
			+ 'suePerson => name: sue, age: 40, '
			+ 'lilPerson => name: lil, age: 40, '
			+ 'aPerson => car: ford';
	assertEquals( 'a/= hash to string', resStr, hash.toString() );
}

function testSetMaxGoNoGo(){
	var goNoGoType = { None:0, Green:1, Yellow:2, Red:3 };
	var aRec = {"temperatureGoNoGo": goNoGoType.None, 
				"rainGoNoGo": goNoGoType.Red,
				"windGoNoGo": goNoGoType.Yellow };
	var bRec = {"temperatureGoNoGo": goNoGoType.Red,
				"rainGoNoGo": goNoGoType.Yellow,
				"windGoNoGo": goNoGoType.Green };
	var cRec = {"temperatureGoNoGo": goNoGoType.Yellow,
				"rainGoNoGo": goNoGoType.Green,
				"windGoNoGo": goNoGoType.Red };
	var dRec = {"temperatureGoNoGo": goNoGoType.Green, 
				"rainGoNoGo": goNoGoType.Green,
				"windGoNoGo": goNoGoType.Yellow };
	hash.putRec('0122', aRec);
	hash.putRec('0224', bRec);
	hash.putRec('0326', cRec);
	hash.putRec('0428', dRec);
	debug( 'toString', hash.toString());
	hash.setGoNoGo();
}

